using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;

namespace Matrix.Configuration
{
    /// <summary>
    /// EntityFrameworkCore模块
    /// </summary>
    [DependsOn(
        typeof(MatrixConfigurationDomainModule),
        typeof(AbpEntityFrameworkCoreModule)
    )]
    public class MatrixConfigurationEntityFrameworkCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<MatrixConfigurationDbContext>(options =>
            {
                options.AddDefaultRepositories(includeAllEntities: true);
            });

            Configure<AbpDbContextOptions>(options =>
            {
                options.PreConfigure<MatrixConfigurationDbContext>(dbContextOptions =>
                {
                    // 数据库预配置 - 在Host模块中配置具体的数据库连接
                });
            });

            // 配置自定义仓储
            context.Services.AddTransient<IConfigurationRepository, ConfigurationRepository>();
        }
    }
}